package com.weds.ticket.ticket.schedule;

import com.weds.ticket.ticket.data.Repository;
import com.weds.ticket.ticket.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @Description TODO
 * @Author lihw
 * @Date 2025/8/14 下午5:44
 */
@Service
public class StockSchedule {

    @Autowired
    StockService stockService;

    @Scheduled(fixedRate = 10000)
    public void stockSchedule() {
        // 获取股票列表
        Set<String> codeList = Repository.getCodeList();
        if (codeList == null || codeList.isEmpty()) {
            return;
        }
        // 遍历股票列表
        for (String code : codeList) {
            // 获取股票数据
            stockService.fetchStockData(code);
        }
        System.out.println("----------------------------------");
    }
}
